<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>点击跳转</button>
    <script>
        let btn = document.querySelector('button');
        btn.addEventListener('click', function () {
            //location
            // window.location.assign('http://www.itcast.com');
            // window.location.reload();   //强制刷新

            //navigator
            // if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
            //     window.location.href = "https://m.jd.com";     //手机
            // } else {
            //     window.location.href = "https://www.itcast.cn";     //电脑
            // }

            //history
            // history.forward();   //前进功能
            // history.back();      //后退功能
            // history.go();        //前进(参数大于0)或后退(参数小于0)功能
        });
    </script>
</body>

</html>